<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Return the LDAP error number of the last LDAP command</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-err2str.html">ldap_err2str</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ldap-error.html">ldap_error</a></div>
 <div class="up"><a href="ref.ldap.html">LDAP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.ldap-errno" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ldap_errno</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">ldap_errno</span> &mdash; <span class="dc-title">Return the LDAP error number of the last LDAP command</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ldap-errno-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>ldap_errno</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
   )</div>

  <p class="para rdfs-comment">
   Returns the standardized error number returned by the last LDAP command.
   This number can be converted into a textual error message using
   <span class="function"><a href="function.ldap-err2str.html" class="function">ldap_err2str()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ldap-errno-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">link_identifier</code></em></dt>

     <dd>

      <p class="para">
       An LDAP link identifier, returned by <span class="function"><a href="function.ldap-connect.html" class="function">ldap_connect()</a></span>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ldap-errno-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Return the LDAP error number of the last LDAP command for this
   link.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ldap-errno-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   Unless you lower your warning level in your <var class="filename">php.ini</var> sufficiently or
   prefix your LDAP commands with @ (at) characters to suppress warning
   output, the errors generated will also show up in your HTML output.
   <div class="example" id="example-4304">
    <p><strong>Example #1 Generating and catching an error</strong></p>
<div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;This&nbsp;example&nbsp;contains&nbsp;an&nbsp;error,&nbsp;which&nbsp;we&nbsp;will&nbsp;catch.<br /></span><span style="color: #0000BB">$ld&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$bind&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;syntax&nbsp;error&nbsp;in&nbsp;filter&nbsp;expression&nbsp;(errno&nbsp;87),<br />//&nbsp;must&nbsp;be&nbsp;"objectclass=*"&nbsp;to&nbsp;work.<br /></span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;&nbsp;@</span><span style="color: #0000BB">ldap_search</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"o=Myorg,&nbsp;c=DE"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"objectclass"</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$res</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"LDAP-Errno:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">ldap_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"LDAP-Error:&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">ldap_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">"Argh!&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_get_entries</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">"count"</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;matching&nbsp;entries.&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ldap-errno-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ldap-err2str.html" class="function" rel="rdfs-seeAlso">ldap_err2str()</a> - Convert LDAP error number into string error message</span></li>
    <li class="member"><span class="function"><a href="function.ldap-error.html" class="function" rel="rdfs-seeAlso">ldap_error()</a> - Return the LDAP error message of the last LDAP command</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-err2str.html">ldap_err2str</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ldap-error.html">ldap_error</a></div>
 <div class="up"><a href="ref.ldap.html">LDAP 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
